<template>
  <div>
    <div class="banner" @click="handleBannerClick">
      <img class="banner-img" :src="bannerImg" alt />
      <div class="banner-info">
        <div class="banner-tittle">{{this.sightName}}</div>
        <div class="banner-number">
          <span class="iconfont">&#xe67d;</span>
          {{this.bannerImgs.length}}
        </div>
      </div>
    </div>
    <fade-animation>
    <!-- 弹出框轮播画廊 -->
    <banner-gallary v-show="showGallary" :imgs="bannerImgs" @close="handleGallaryClose"></banner-gallary>
    </fade-animation>
  </div>
</template>

<script>
import BannerGallary from "common/gallary/Gallary.vue";
import FadeAnimation from 'common/fade/FadeAnimation'
export default {
  name: "DetailBanner",
  props: {
    sightName: String,
    bannerImg: String,
    bannerImgs: Array
  },
  components: {
    BannerGallary,
    FadeAnimation
  },
  data() {
    return {
      showGallary: false //控制画廊的显示和隐藏 点击图片后
    };
  },
  methods: {
    //点击后打开画廊
    handleBannerClick() {
      this.showGallary = true;
    },
    //接收子组件传递出来的事件 关闭画廊
    handleGallaryClose() {
      this.showGallary = false;
    }
  }
};
</script>

<style lang="stylus" scoped>
.banner {
  position: relative;
  overflow: hidden;
  height: 0;
  padding-bottom: 55%;

  .banner-img {
    width: 100%;
  }

  .banner-info {
    display: flex;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 44px;
    line-height: 1.2rem;
    color: #fff;
    background-image: linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.8));

    .banner-tittle {
      flex: 1;
      font-size: 0.64rem;
      padding: 0 0.4rem;
    }

    .banner-number {
      height: 0.64rem;
      line-height: 0.64rem;
      margin-top: 0.28rem;
      padding: 0 0.8rem;
      border-radius: 0.4rem;
      background: rgba(0, 0, 0, 0.8);
      font-size: 0.48rem;

      .banner-icon {
        font-size: 0.48rem;
      }
    }
  }
}
</style>
